function [ w ] = getw( n )
%UNTITLED4 Summary of this function goes here
%   Detailed explanation goes here

    for i=1:n-1
        b(i,i+1)=1/4;
        b(i+1,i)=1/4;
    end
    m=sparse(n*n,n*n);
    for i=1:n
        m((i-1)*n+1:i*n,(i-1)*n+1:i*n)=b;
    end

    for i=1:n-1
        m(i*n+1:(i+1)*n,(i-1)*n+1:i*n)= eye(n)/4;
        m((i-1)*n+1:i*n,i*n+1:(i+1)*n)= eye(n)/4;
    end
    p=max(eig(m));
    w=2/(1+sqrt(1-p^2));
end

